home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / linux / atari / source / source.lzh / atari-linux-0.01pl3 / m68k / machasm.S < prev    next >
Encoding:
Text File  |  1994-06-09  |  2.3 KB  |  117 lines

  1. /*
  2.  * This file contains the code necessary to switch
  3.  * tasks on an m680x0 linux machine.
  4.  * The following LTSS_ constants must be changed if the m68k_struct in
  5.  * include/linux/sched.h is changed.
  6.  * The LBI_CPU constant must be changed if the boot_info structure is 
  7.  * changed. 
  8.  */
  9.  
  10. LFLUSH_I_AND_D = 0x00000808
  11. LBI_CPU = 4
  12. LTSS_SR = 48
  13. LTSS_REGS = 0
  14. LTSS_FS = 50
  15. LTSS_CRP = 60
  16. LTSS_FPREGS = 68
  17. LTSS_FPCNTL = 164
  18. LTSS_FPSTATE = 176
  19.  
  20. .text
  21.  
  22. .globl _resume
  23.     .even
  24. _resume:
  25.     /* current tasks task_struct */
  26.     movel    _current,a0
  27.  
  28.     /* offset of tss struct (processor state) from beginning
  29.        of task struct */
  30.     movel    sp@(8),a1
  31.     addl    a1,a0
  32.  
  33.     /* save sr */
  34.     movew    sr,a0@(LTSS_SR)
  35.  
  36.     /* disable interrupts */
  37.     oriw    #0x0700,sr
  38.  
  39.     /* save fs (sfc,dfc) (may be pointing to kernel memory) */
  40.     movec    sfc,d0
  41.     movew    d0,a0@(LTSS_FS)
  42.  
  43.     /* save non-scratch registers */
  44.     moveml    d2-d7/a2-a7,a0@(LTSS_REGS)
  45.  
  46.     /* save floating point state */
  47.     fsave    a0@(LTSS_FPSTATE)
  48.     tstw    a0@(LTSS_FPSTATE)
  49.     beqs    1f        /* NULL state, no need to save regs */
  50.     fmovemx fp0-fp7,a0@(LTSS_FPREGS)
  51. |    fmovem    fpiar/fpcr/fpsr,a0@(LTSS_FPCNTL)
  52.     fmovem    fpcr/fpsr,a0@(LTSS_FPCNTL)
  53. 1:
  54.  
  55.     /* switch current task */
  56.     movel    sp@(4),a0
  57.     movel    a0,_current
  58.     /* get pointer to tss struct */
  59.     addl    a1,a0
  60.  
  61.     /* 68040 ? */
  62.     btst    #2,_boot_info+LBI_CPU+3
  63.     bnes    1f
  64.  
  65.     /*
  66.      * switch address space
  67.      */
  68.  
  69.     /* flush MC68030/MC68020 caches (they are virtually addressed) */
  70.     movec    cacr,d0
  71.     oril    #LFLUSH_I_AND_D,d0
  72.     movec    d0,cacr
  73.  
  74.     /* switch the root pointer */
  75.     pmove    a0@(LTSS_CRP),crp
  76.  
  77.     /* flush address translation cache (probably not needed */
  78.     pflusha
  79.  
  80.     bras    2f    /* skip m68040 stuff */
  81.  
  82. 1:
  83.     /*
  84.      * switch address space
  85.      */
  86.  
  87.     /* flush address translation cache (user entries) */
  88.     .word    0xf510            /* pflushan */
  89.  
  90.     /* switch the root pointer */
  91.     movel    a0@(LTSS_CRP+4),d0
  92.     .long    0x4e7b0806        /* movec d0,urp */
  93.  
  94.  
  95. 2:
  96.     /* restore floating point unit state */
  97.     tstw    a0@(LTSS_FPSTATE)
  98.     beqs    1f        /* NULL state; no need to load regs */
  99.     fmovemx a0@(LTSS_FPREGS),fp0-fp7
  100. |    fmovem    a0@(LTSS_FPCNTL),fpiar/fpcr/fpsr
  101.     fmovem    a0@(LTSS_FPCNTL),fpcr/fpsr
  102. 1:
  103.     frestore a0@(LTSS_FPSTATE)
  104.  
  105.     /* restore non-scratch registers */
  106.     moveml    a0@(LTSS_REGS),d2-d7/a2-a7
  107.  
  108.     /* restore fs (sfc,dfc) */
  109.     movew    a0@(LTSS_FS),a1
  110.     movec    a1,sfc
  111.     movec    a1,dfc
  112.  
  113.     /* restore status register */
  114.     movew    a0@(LTSS_SR),sr
  115.  
  116.     rts
  117.